package com.dyna.digit.flowable.domain.request;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List;

/**
 * 启动流程实体
 * 先不把项目信息放到任务中去，而是放到库里
 * 但是保留项目id和项目名称，方便后续查询
 * @author zhoucaiwang
 * @date 2023/11/8
 */

@Data
public class TaskReq {

    @ApiModelProperty(value = "流程定义key", notes = "使用key方便流程更新后依旧能查询到不同部署的流程之间的数据")
    @NotBlank(message = "流程定义key不能为空")
    private String processDefinitionKey;

    @ApiModelProperty(value = "项目id", notes = "因为一定是先保存项目再提交，提交相当于启动流程")
    @NotNull(message = "项目id不能为空")
    private  Integer projectId;

    @ApiModelProperty(value = "项目名称")
    @NotBlank(message = "项目名称不能为空")
    private String projectName;

    @Valid
    @Size(min = 16, max = 16, message = "用户审批人数参数不正确")
    @ApiModelProperty(value = "流程用户")
    private List<FlowUser> flowUserList;

    @Data
    public static class FlowUser implements Serializable {

        @NotBlank(message = "审批用户变量名不能为空")
        @ApiModelProperty(value = "审批用户变量名")
        private String assigneeVarName;

        @NotNull(message = "审批用户id不能为空")
        @ApiModelProperty(value = "用户id")
        private Integer userId;

    }

}
